package com.hzhk.happyrent.ui.adapter.card;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.hzhk.happyrent.App;
import com.hzhk.happyrent.R;
import com.hzhk.happyrent.bean.card.BankHotModel;
import com.hzhk.happyrent.ui.adapter.BaseAdapter;
import com.hzhk.happyrent.utils.glide.ShowImageUtils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by soft_zzc on 2017/11/25.
 */
public class BankHotAdapter extends BaseAdapter<BankHotModel.DataBean.BankBean> {


    private Logger log = LoggerFactory.getLogger(this.getClass().getName());
    private BankHotModel bankHotModel;

    public BankHotAdapter(Context context) {
        super(context);
        log.debug("jump into CardHotAdapter");
    }

    @Override
    public View getView(int position, View convertView, ViewGroup arg2) {
        ViewHolder viewHolder;
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.item_bank_hot, null);
            viewHolder = new ViewHolder(convertView,position,mContext);
            viewHolder.setData(mList.get(position));
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
            viewHolder.setData(mList.get(position));
        }
        return convertView;
    }

    static class ViewHolder {

        @BindView(R.id.card_top_pic)
        ImageView cardTopPic;
        @BindView(R.id.bank_hot_text1)
        TextView bankHotText1;
        @BindView(R.id.bank_hot_text2)
        TextView bankHotText2;
        int position ;
        private Context context;
        ViewHolder(View view,int position,Context mConText) {
            this.position = position;
            this.context = mConText;
            ButterKnife.bind(this, view);
        }

        public void setData(final BankHotModel.DataBean.BankBean bankBean) {

            ShowImageUtils.showImageView(App.getContext(),cardTopPic,bankBean.getImage());
            bankHotText1.setText(bankBean.getTitle());
            bankHotText2.setText(bankBean.getDesc());
           /* liCardHotBank.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent intent = new Intent(context,HotBankActivity.class);
                    Bundle bundle = new Bundle();
                    bundle.putString("id",bankBean.getId());
                    bundle.putString("title",bankBean.getTitle());
                    intent.putExtras(bundle);
                    context.startActivity(intent);
                }
            });*/

        }
    }
}
